<template>
<!--帮助中心-->
  <div class="content padding250">
    <headers></headers>
    <!--<carousel></carousel>-->
    <p class="banner padding88"><img :src="sliderImg" alt="" height="200px" width="100%"></p>
    <div class="divider ">
      <div class="auto">
        <router-link to="/">首页</router-link><span>></span><span>帮助中心</span>
      </div>
    </div>
    <div class="auto">
      <!--<p class="titles">帮助中心</p>-->
      <div class="container clearfix font14">
        <ul class="new_list">
          <li class="clearfix" v-for="help in helps">
            <a href="" @click.stop.prevent="goHelp(help.id)">
              <span>{{help.htmlTitle}}</span><span class="pull-right">{{help.createTime | timeFilter}}<Icon type="ios-arrow-forward"  size="20"/></span>
            </a>
          </li>
        </ul>
      </div>
      <div class="pageout txt-center"><Page :total="total" :current="pageNumber" :page-size="size" @on-change="changePage"/></div>
    </div>
    <Spin fix v-show="isSpinShow" >
      <div class="loader">
        <Icon type="ios-loading" size=26 class="demo-spin-icon-load"></Icon>
        <div class="font14">加载中...</div>
      </div>
    </Spin>
    <footers></footers>
  </div>
</template>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="less" rel="stylesheet/less">
  /* 旋转效果 */
  .demo-spin-icon-load{
    animation: ani-demo-spin 1s linear infinite;
  }
  @keyframes ani-demo-spin {
    from { transform: rotate(0deg);}
    50% { transform: rotate(180deg);}
    to { transform: rotate(360deg);}
  }
  /* 假如内容过长，一屏放不下，滚动条下拉覆盖不全 */
  .ivu-spin-fix {
    position: fixed;
  }

  .banner{
    height: 260px;
  }
  .divider{
    height: 53px;
    background-color: #fff;
    font-size: 14px;
    color: #957960;
    line-height: 53px;
    text-align: left;
    margin-bottom: 30px;
    box-shadow: 5px 1px 10px #ccc;
    a{
      color: #957960;
      &:hover{
        color: #9C7649;
        font-weight: 700;
      }
    }
    span{
      margin: 0 10px;
    }
  }

  .content{
    //background-color: #f5f5f5;
    text-align: left;
    .titles{
      font-size: 20px;
      color: #000;
      margin: 20px 0 25px 0;
      padding: 15px 20px ;
      background-color: #fff;
    }
    .container{
      background-color: #fff;
      padding:  0px;
      line-height: 30px;
      .new_list li{
        border-bottom: 1px dashed #dbdbdb;
        padding-bottom: 15px;
        margin-bottom: 15px;
        a{
          color: #333;
          display: block;
          .pull-right{
            color: #999;
            i{
              margin-bottom: 5px;
              margin-left:10px;
            }
          }
        }
      }
      .new_list li:last-child{
        border-bottom: none;
        margin-bottom: 0;
        padding-bottom: 0;
      }
    }
    .pageout{
      margin-top: 30px;
    }
  }
</style>
<script type="text/ecmascript-6">
  import headers from '../template/header'
  import footers from '../template/footer'
  import carousel from '../template/carousel'
  import {issuePageWeb,sliderPC} from '../../http'
  import {timeFilter} from "../../myFilters"
    export default {
        name: '',
        props: {},
        data() {
            return {
              isSpinShow:false,
              total:0,
              pageNumber:1,
              size:8,
              helps:'',
              sliderImg:''
            };
        },
        methods: {
          //查看帮助详情
          goHelp(helpId){
            this.$router.push({
              name: 'helpdetail',
              query:{
                helpId:helpId
              }
            })
          },
          //换页
          changePage(pageNumber){
            if(this.isSpinShow === false) {
              this.isSpinShow = true;
              this.pageNumber = pageNumber;
              issuePageWeb({pageNumber:this.pageNumber,pageSize:this.size}).then(res => {
                if(res.code === 200){
                  this.isSpinShow = false;
                  this.helps = res.data.questions.rows;
                  this.total = res.data.questions.total;
                }else {
                  this.isSpinShow = false;
                  this.$Notice.warning({
                    title: "帮助中心提醒",
                    desc: res.info,
                    duration: 3,
                  });
                }
              })
            }
          },
          getHelp(){
            if(this.isSpinShow === false) {
              this.isSpinShow = true;
              //获取封面图
              sliderPC({sliderType:'8'}).then(res =>{
                this.sliderImg = res.data.slider.sliderImg;
              }).catch()
              issuePageWeb({pageNumber:1,pageSize:this.size}).then(res => {
                if(res.code === 200){
                  this.isSpinShow = false;
                  this.helps = res.data.questions.rows;
                  this.total = res.data.questions.total;
                }else {
                  this.isSpinShow = false;
                  this.$Notice.warning({
                    title: "帮助中心提醒",
                    desc: res.info,
                    duration: 3,
                  });
                }
              })
            }
          }
        },
        created() {
         this.getHelp();
        },
        components: {
          headers,
          footers,
          carousel
        }
    }
</script>
